home *** CD-ROM | disk | FTP | other *** search
- Path: news.compuserve.com!newsmaster
- From: Philippe Verdy <100105.3120@compuserve.com>
- Newsgroups: comp.lang.c++
- Subject: Re: Does Borland share these MSVC++ problems?
- Date: 24 Mar 1996 11:58:19 GMT
- Organization: CompuServe Incorporated
- Message-ID: <4j3dcr$pd6@arl-news-svc-2.compuserve.com>
- NNTP-Posting-Host: dd22-055.compuserve.com
-
- john@meenie.Princeton.EDU (John Saponara) s'Θcrit :
- > Folks,
- >
- > As I was unable to wait long enough on the phone for Borland pre-sale
- > tech support (cannot afford to be on hold that long and that far away),
- > please let me know if Borland differs from MS Visual C++ in any of the
- > following traits (all of which have frustrated me regarding VC++).
- > I have come to expect these features from using GNU C++, but must
- > diagnose a particular problem using a C++ compiler for PCs.
- >
- > 1. Do index variables declared in the for statement persist after the loop?
- >
- No. index variables have local scope within the for loop body
- >
- > 2. Is there no `bool' builtin type?
- >
- Yes or no. Depending on the compiler implementation, bool may
- be a built-in type or a class type. Whatever the option, you
- should always include <bool.h> to get bool support.
- >
- > 3. Must I return a value from a non-void function
- > even in a branch that calls exit(1)?
- >
- Normally no. The compiler should contain a pragma declaration
- for the exit() function defined in <stdlib.h> that explicitly
- declares this function as either never returning or as having
- special flow control. The same applies to longjmp() and raise().
- Sometimes, this pragma is not supported by the compiler. The
- best thing to do is to always use an unconditional return
- statement at the end of your function, which should only be
- reached by normal cases when exit() is not called.
- >
- > 4. Is there no list of candidate conversions to help
- > me find the cause of the compiler error:
- > `>' : 2 overloads have similar conversions
- > (for various operators)?
- >
- Some compilers have more explicit messages to help you.
- However, avoid to write several conversion operators from
- your class definitions. Use only one for built-in scalars,
- else you will encounter many ambiguities.
- Refrain using conversions from a class object to a built-in
- pointer type (like char *, or void *).
- Example: you should not define a conversion from
- a class to a (char *), to allow simple streaming. Replace it
- with a public "const char * str() const" method, that you
- can use to implement a streaming operator like:
- "ostream & operator<< (ostream &os, const class A &object);"
- in the case you do not want this operator to be explicitly
- declared as a friend function.
- >
- > 5. Are the POSIX functions (particularly sleep, link, unlink) unavailable?
- >
- No. You should include the appropriate include files for your
- platform. However, these are C linkage functions. So you can
- include these include files within a:
- extern "C" {
- #include <C-library.h>
- ...
- }
- if your system does not provide support for C++ in its header
- files.
- >
- > 6. Is there no iostream extension that takes the same vararg list as printf()?
- > In g++ you can write, for example: cout.form( "%s\n", charArray );
- >
- If it is missing, you can add it very simply in the ostream
- class definition:
- --- iostream.h -----
- extern "C" {
- #include <stdio.h> // support for ANSI-C sprintf()
- #include <stdarg.h> // support for ANSI-C va_*
- };
-
- class ostream {
- public:
- ...
- void form(const char *format, ...);
- };
- void ostream::form(const char *format, ...)
- {
- char *buffer[1024];
- va_list args;
-
- va_start(format, args);
- vsprintf(buffer, format, args);
- va_end(args);
- *this << buffer;
- }
- >
- > I don't want to incite flames, only to know which (if any)
- > of these problems Borland C++ shares with MS Visual C++.
- >
- > Thanks,
- > John
- >
-
-